<%include pub/head.html%>
    </head>

    <body>
        <%include pub/nav.html%>
            <div class="home-p pages-head2 text-center">
                <div class="container">
                    <h1>学生作品</h1>
                    <p>优秀作品展示</p>
                </div>
            </div>
            <section class="section xu-mian-panel">
                <div class="container">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="works-search-panel">
                                <div class="w-search-bar">
                                    <input type="text" id="searchworks" name="searchworks" placeholder="作品搜索..."
                                        value="<%= keyword %>" />
                                    <button type="button" id="w-search-btn" class="w-search-btn"><img
                                            src="/img/works/search.svg" width="22px" alt="搜索" /></button>
                                </div>
                            </div>
                            <div class="btn-group btn-group-toggle justify-content-center d-flex">
                                <% let a='' , b='' , c='' , d='' , e='' ,f='' ,g='' ; if(types=='a' ){ a='active' }else
                                    if(types=='b' ){ b='active' }else if(types=='c' ){ c='active' }else if(types=='d' ){
                                    d='active' }else if(types=='e' ){ e='active' }else if(types=='f' ){ f='active' }else
                                    if(types=='g' ){ g='active' } %>
                                    <a href="/works?page=1&type=a&sort=zan" class="btn btn-primary <%- a%>">所有</a>
                                    <a href="/works?page=1&type=b&sort=zan" class="btn btn-primary <%- b%>">游戏</a>
                                    <a href="/works?page=1&type=c&sort=zan" class="btn btn-primary <%- c%>">动画</a>
                                    <a href="/works?page=1&type=d&sort=zan" class="btn btn-primary <%- d%>">音乐</a>
                                    <a href="/works?page=1&type=e&sort=zan" class="btn btn-primary <%- e%>">模拟</a>
                                    <a href="/works?page=1&type=f&sort=zan" class="btn btn-primary <%- f%>">娱乐</a>
                                    <a href="/works?page=1&type=g&sort=zan" class="btn btn-primary <%- g%>">故事</a>
                            </div>
                        </div>
                        <%if(workslist.length> 0){ let listlength = workslist.length %>
                            <input type="hidden" value="<%= pagecount%>" id="compagecount">
                            <input type="hidden" value="<%= compageid%>" id="compageid">
                            <input type="hidden" value="<%= sorttype%>" id="sorttype">
                            <input type="hidden" value="<%= types%>" id="pagetypes">
                            <ul class="xu-card-bar worklist row col-lg-12" style="margin-left: -30px;">
                                <% for(let i=0; i < listlength; i++){%>
                                    <li>
                                        <div class="xu-list-div">
                                            <a href="/works/content/1/<%- workslist[i]._id%>?released=<%- workslist[i]._id %>"
                                                class="xu-content-img">
                                                <img src="/released/covers/<%- workslist[i].covers%>"
                                                    alt="<%- workslist[i].title %>" />
                                            </a>
                                            <div class="xu-list-border">
                                                <a href="/works/content/1/<%- workslist[i]._id%>?released=<%- workslist[i]._id %>"
                                                    class="xu-contant-title">
                                                    <%- workslist[i].title %>
                                                </a>
                                                <div class="xu-user-panel">
                                                    <% let looknum=workslist[i].looks; let zannum=workslist[i].zan;
                                                        if(looknum> 1000){
                                                        looknum = (looknum/1000).toFixed(1) +'k'
                                                        }
                                                        if(zannum > 1000){
                                                        zannum = (zannum/1000).toFixed(1) +'k'
                                                        }
                                                        %>
                                                        <ul class="user-eyes">
                                                            <li class="likes"><i class="fa fa-thumbs-o-up"></i>
                                                                <%- zannum %>
                                                            </li>
                                                            <li class="eyes"><i class="fa fa-eye"></i>
                                                                <%- looknum %>
                                                            </li>
                                                        </ul>
                                                </div>
                                                <div class="xu-user-panel border-top">
                                                    <a href="/users/userindex/<%- workslist[i].user._id %>"
                                                        target="_blank">
                                                        <img src="<%- workslist[i].user.headimg %>"
                                                            class="xu-user-headimg" />
                                                        <span>
                                                            <%- workslist[i].user.nickname %>
                                                        </span>
                                                    </a>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                    <%}%>
                            </ul>
                            <%}else{%>
                                <div class="note-nowroks">
                                    <img src="/img/icon/radar.svg" width="30"> 没有相关数据
                                </div>
                                <%}%>
                    </div>
                    <div id="work-pagination" class="pager row"></div>
            </section>
            <%include pub/foot.html%>
                <%include pub/script.html%>
                    <script type="text/javascript">
                        $(function () {
                            let sorttype = $('#sorttype').val();
                            let pagetypes = $('#pagetypes').val();
                            var limittxt = 'page=';
                            var countnums = $('#compagecount').val();
                            var currentPage = parseInt($('#compageid').val());
                            if (countnums > 29) {
                                var total = Math.ceil(countnums / 30);
                                var prev = currentPage - 1;
                                var next = currentPage + 1;
                                $.jqPaginator('#work-pagination', {
                                    totalPages: total,
                                    visiblePages: 5,
                                    currentPage: currentPage,
                                    page: '<li class="page"><a href="/works?' + limittxt + '{{page}}' + '&type=' + pagetypes + '&sort=' + sorttype + '">{{page}}</a></li>',
                                });
                            }
                        })
                    </script>
    </body>

    </html>